package edu.sctu.nieyu.day20150617;

import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

/**
 * Created by user01 on 2015/6/17.
 */
public class ReaderUtil {

  public void addFile(File file){
      while (!file.exists()){
          file.mkdir();
      }
  }
    public boolean createNewFile(String filename){
       File file = new File(filename);
        if (!file.exists()){
            try {
                return file.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return false;
    }

    public void getReader(){

        int count = 0;
        FileWriter fileWriter;
        FileReader fileReader;

        try {
            fileWriter = new FileWriter("D://test2//duru.txt");
            fileReader = new FileReader("D://test2//字符流练习.txt");
            while ((count = fileReader.read())!=-1){
                fileWriter.write(count);
                System.out.println(count);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
